package com.caigou.modules.service.adapter

import android.widget.TextView
import com.caigou.modules.service.R
import com.caigou.modules.service.baen.WebsiteCollectItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/11/10
 */
class WebsiteCollectItemAdapter(dataset: MutableList<WebsiteCollectItemBean>, private val callback: IItemCallback) :
    BaseQuickAdapter<WebsiteCollectItemBean, BaseViewHolder>(R.layout.item_website_collect_list, dataset),
    LoadMoreModule {
    override fun convert(holder: BaseViewHolder, item: WebsiteCollectItemBean) {
        holder.setText(R.id.item_website_collect_tv_desc, item.nickName)
        holder.getView<TextView>(R.id.item_website_collect_tv_enter).setOnClickListener {
            callback.onEnter(item)
        }
        holder.getView<TextView>(R.id.item_website_collect_tv_delete).setOnClickListener {
            callback.onDelete(item)
        }
    }

    interface IItemCallback {
        fun onDelete(item: WebsiteCollectItemBean)
        fun onEnter(item: WebsiteCollectItemBean)
    }
}